package com.itic.web.mem.login.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.itic.appbase.framework.common.controller.BaseController;
import com.itic.ht.mem.member.persistence.model.WebMember;
import com.itic.web.mem.login.service.AppMemberService;
import com.itic.web.qo.RegisterData;
import com.itic.web.qo.TokenData;
import com.itic.web.ro.ResResult;



@Controller
@RequestMapping(value="/app/mem")
public class AppMemMainController extends BaseController {
    @Autowired
    private AppMemberService appMemberService;

    

    
    /**
     * 获取验证码-1
     * @param account
     * @return 返回发送成功 还是失败  200成功 其它失败 也有可能是得新生成 token
     */
    @RequestMapping(value="/getVerifCode", method= RequestMethod.POST )
    @ResponseBody
    public ResResult getVerifCode(WebMember temp){
         ResResult ro = appMemberService.getVerificationCode(temp);
         return ro;
    }
    
    /**
     * 获取token-2   可以获取token 也可以建立上下级关系
     * @param account verification invitationCode 和 上级的 account
     * @return account token
     */
    @RequestMapping(value="/getToken")
    @ResponseBody
    public ResResult getToken(WebMember temp){
    	ResResult ro = appMemberService.getToken(temp);
    	return ro;
    }
    
    /**
     * 获取token-2   可以获取token 也可以建立上下级关系
     * @param account verification invitationCode 和 上级的 account
     * @return account token
     */
    @RequestMapping(value="/assertToken")
    @ResponseBody
    public ResResult assertToken(TokenData temp){
    	ResResult ro = appMemberService.assertToken(temp);
    	return ro;
    }
    
    /**
     * 用户注册- 3
     * @param  account
     * @return account token
     */
    @RequestMapping(value="/appRegister")
    @ResponseBody
    public ResResult getPassWord(RegisterData data){
    	ResResult ro = appMemberService.getPassWord(data);
    	return ro;
    }
    
    /**
     * 建立上下级关系 - 4
     * @param  account 用户帐号  
     * @return account token
     */
    @RequestMapping(value="/setRelation")
    @ResponseBody
    public ResResult setRelation(TokenData temp,String subjectId){
    	ResResult ro = appMemberService.setRelation(temp,subjectId);
    	return ro;
    }

//
//	/**
//	 * 微信支付
//	 * @param info
//	 * @return
//	 */
//	@RequestMapping(value="/paywx")
//	@ResponseBody
//	public ResResult signwx(WebMember temp) {
//////		TokenData data=new TokenData ();
//////		data.setToken(request.getParameter("token"));
////		MemberOrder temp =new MemberOrder();
//////		String itemId=request.getParameter("itemId");
//////		String orderType =request.getParameter("orderType");
////		temp.setOrderType(orderType);
////		return  weiXinService.precreateOrderByWX(temp,data,itemId,request);
//		System.out.println("**********");
//		return null;
//	}
	
	
    

    
}